package com.lxl.demo;


/**
 *
 * @author lxl
 * @description
 * @since 2025-10-09 15:45
 **/


public class Demo13 {

    void moveZeros(int[] nums) {
        int slow = 0; int fast = 0;
        while (fast < nums.length) {
            if (nums[fast] != 0) {
                swap(nums, slow++, fast);

            }
            fast++;
        }
    }


    void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }

    public static void main(String[] args) {
        Demo13 demo13 = new Demo13();
        int[] nums = {2, 1, 0, 3, 12};
        demo13.moveZeros(nums);
    }
}
